/*
 * ManualDownLoadDlg.c
 *
 *  Created on: 2009-11-22
 *      Author: allan
 */

#include "include/ShowLyric.h"
#include "include/ManualDownLoadDlg.h"

struct
{
	SongInfo info;
}g_DownInfo = {0};

void ManualDownloadDlgInit(GladeXML* xml, SongInfo info)
{
	XML_CONNECT_SIGNAL2(xml, on_btnOK_clicked, xml);
	XML_CONNECT_SIGNAL2(xml, on_btnCancel_clicked, xml);
	g_DownInfo.info = info;
}

void on_btnOK_clicked(GtkWidget * widget, GladeXML* xml)
{
	GtkWidget* pManualDownloadDlg = glade_xml_get_widget(xml, "ManualDownLoadDlg");
	gtk_widget_hide(GTK_WIDGET(pManualDownloadDlg));

	LyricDebug("正在手动下载歌词......\n");
	// 手动下载歌词
	GtkWidget * title = glade_xml_get_widget(xml, "entryTitleName");
	GtkWidget * artist = glade_xml_get_widget(xml, "entryArtistName");

	strncpy(g_DownInfo.info.szTitle, gtk_entry_get_text(GTK_ENTRY(title)), MAX_PATH);
	strncpy(g_DownInfo.info.szArtist, gtk_entry_get_text(GTK_ENTRY(artist)), MAX_PATH);

	SearchLyric(g_DownInfo.info, FALSE, gtk_combo_box_get_active(GTK_COMBO_BOX(glade_xml_get_widget(xml, "cbSearchApp"))), TRUE);
}

void on_btnCancel_clicked(GtkWidget * widget, GladeXML* xml)
{
	GtkWidget* pManualDownloadDlg = glade_xml_get_widget(xml, "ManualDownLoadDlg");
	gtk_widget_hide(pManualDownloadDlg);
}
